import com.sun.org.apache.xpath.internal.axes.OneStepIterator;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-07-31
 * Time: 10:09
 */


public class Test_0731 {
/*  dest1--起始位置
*   dest2--中转位置
*   dest3--目标位置
* */

    public static void hanoi_tower(int n, char dest1, char dest2, char dest3) {
        if (n == 1) {
            move(dest1, dest3);
            return;
        } else {
            //1.把n-1个盘 从dest1借助dest3放到dest2上
            hanoi_tower(n - 1, dest1, dest3, dest2);

            //2.将dest1上最地下那个盘从dest1直接放到dest3上 完成将最大得先放在目标中
            move(dest1, dest3);

            //3.把dest2上得n-1盘从dest2借助dest1放到dest3上 完成整个挪动
            hanoi_tower(n - 1, dest2, dest1, dest3);
        }
    }

    //模拟盘子移动
    public static void move(char dest1, char dest2) {
        System.out.print(dest1 + "->" + dest2 + " ");
    }

    //经典汉诺塔问题
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        hanoi_tower(n, 'A', 'B', 'C');
    }

    public static void printArray(int[] arr, int sz) {
        for (int i = 0; i < sz; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    //打印一个数组
    public static void main8(String[] args) {
        int[] arr1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        printArray(arr1, arr1.length);
    }

    //创建一个 int 类型的数组, 元素个数为 100, 并把每个元素依次设置为 1 - 100
    public static void main7(String[] args) {

        //静态初始化--在创建数组时不直接指定数据元素个数，而直接将具体的数据内容进行指定
        int [] arr1=new int[]{1,2,3,4,5,6,7,8,9,10};
        int [] arr3={0,1,2,3,4,5,6,7,8,9}; //静态初始化可以省略 new int[],但是编译器编译是会自动还原

        //动态初始化--在创建数组时，直接指定数组中元素的个数
        int [] arr2= new int[10];//为初始化是，默认值为0

    }

    public static void main6(String[] args) {
        //1.数组类型 名=new 类型[元素个数]
        int[] arr = new int[100];
        //数组名 . length 求数组长度
        for (int i = 0; i < arr.length; i++) {
            arr[i] = i + 1;
            System.out.print(arr[i] + " ");
        }
    }

    public static int factorial(int n) {
        if (n <= 1) {
            return 1;
        }
        return n * (factorial(n - 1));
    }

    //递归求解n得阶乘
    public static void main5(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(factorial(n));
    }

    public static int fib(int n) {
        if (n < 3) {
            return 1;
        } else {
            return fib(n - 1) + fib(n - 2);
        }
    }

    //斐波那契数
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(fib(n));
    }

    public static int sum_number(int a) {
        if (a < 10) {
            return a;
        }
        return a % 10 + sum_number(a / 10);
    }

    //打印一个数得每一位数之和
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(sum_number(n));
    }

    public static int sum(int a) {
        if (a == 1) {
            return 1;
        }
        return a + sum(a - 1);
    }

    //输出1-n之间数得和
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        System.out.println(sum(a));
    }

    public static void printf_number(int a) {
        if (a < 10) {
            System.out.print(a + " ");

        } else {
            printf_number(a / 10);
            System.out.print(a % 10 + " ");
        }
    }

    //递归打印一个数得每一位数
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        printf_number(n);
    }
}
